If a software error corrupts a data object, or if erroneous data updates the data object, a data protection administrator may restore the data object to a previous state that does not include the corrupted or erroneous data. A backup application executes a backup operation either occasionally or continuously to enable this restoration, storing a copy of each desired data object state (such as the values of data and these values' embedding in a database's data structures) within dedicated backup files. When the data protection administrator decides to return the data object to a previous state, the data protection administrator specifies the desired previous state by identifying a desired point in time when the data object was in this state, and instructs the backup application to execute a restore operation to restore a copy of the corresponding backup files for that state to the data object.
Some structured query language servers, such as Microsoft's SQL Server 2012, include an “Always On” availability group, which is a high-availability and disaster-recovery solution that provides an enterprise-level alternative to database mirroring. An availability group maximizes the availability of a set of user databases for an enterprise, and supports a failover environment for a discrete set of user databases, known as availability databases, that fail over together from one server, or node, in a cluster to another server, or node, in the cluster. An availability group supports a set of read-write primary replicas of a database and other sets of corresponding secondary replicas of the database. Secondary replicas may be made available for read-only access and/or some backup operations. A system administrator may specify availability group properties, such as backup preference among primary replicas and secondary replicas for running backup jobs, which can thereby improve backup performance.
Consequently, when a backup application is scheduled to back up a replica of a database in an availability group, the backup application needs to determine whether the current node in a cluster is the preferred node for backing up the replica. Therefore, as an example, SQL Server 2012 exposes a procedure sys.fn_hadr_backup_is_preferred_replica which takes a database replica name as an input and returns whether a current node is the preferred node to be used for backing up the replica.